package Service::CloudService;

use strict;
use warnings;
use 5.010;

use Exporter qw(import);
use Native::DataCollector;


sub list_files_in_dir {
    my $user = shift;
    my $dir = shift;
    my @files = Native::DataCollector::list_files_in_dir("/$user/$dir");

    return @files;
}

sub get_file_by_user_and_path {
    my $user = shift;
    my $file_path = shift;
    
    return Native::DataCollector::get_file_by_path("/$user/$file_path");
}

sub remove_file_by_user_and_path {
    my $user = shift;
    my $file_path = shift;

    return Native::DataCollector::remove_file_by_path("/$user/$file_path");
}

sub rename_file_by_user_and_path {
    my $user = shift;
    my $ori_filepath = shift;
    my $new_filepath = shift;

    return Native::DataCollector::rename_file_by_path("/$user/$ori_filepath", "/$user/$new_filepath");
}

sub add_new_file {
    my ($user_id, $path, $filename, $file) = @_;

    return Native::DataCollector::store_file_by_path("/$user_id/$path", "$filename", $file);
}

sub create_new_folder_in_specified_path {
    my ($user_id, $path, $dir_name) = @_;

    return Native::DataCollector::add_new_folder("/$user_id/$path", "$dir_name");
}

sub save_image_file_to_static {
    my ($file, $filename) = @_;

    return Native::DataCollector::save_static_file("images", $filename, $file);
}

1;
